<?php
/**
 * 用户信息
 */
if(!session_id()) session_start();

//Braintree支付专用--start
include API_ROOT.'/../vendor/Braintree/vendor/autoload.php';

use Braintree\ClientToken;
use think\facade\Db;


class Api_User extends PhalApi_Api
{
	
	public function getRules()
	{
		return array(
			// 新增
			'getShowSetting' => array(
				'id' => array('name' => 'id', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '查询详情的id'),
			),
			'feedback'       => array(
				'uid'     => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'   => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'version' => array('name' => 'version', 'type' => 'string', 'require' => true, 'desc' => '主题版本号'),
				'thumb'   => array('name' => 'thumb', 'type' => 'string', 'require' => true, 'desc' => '封面图片'),
				'model'   => array('name' => 'model', 'type' => 'string', 'desc' => '设备'),
				'content' => array('name' => 'content', 'type' => 'string', 'require' => true, 'desc' => '内容'),
			),
			'level'          => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			'vip'            => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			'setReport'      => array(
				'uid'     => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'   => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'touid'   => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'content' => array('name' => 'content', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '举报内容'),
			),
			
			// 卡密与充值
			'getBalance'     => array(
				'uid'         => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'       => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'type'        => array('name' => 'type', 'type' => 'string', 'desc' => '设备类型，0android，1IOS'),
				'version_ios' => array('name' => 'version_ios', 'type' => 'string', 'desc' => 'IOS版本号'),
			),
			'exchange'       => array(
				'uid'  => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'coin' => array('name' => 'coin', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '钻石数'),
			),
			'coinrecord'     => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'p'     => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default' => 1, 'require' => true, 'desc' => '页数'),
				'pnum'  => array('name' => 'pnum', 'type' => 'int', 'min' => 1, 'default' => 20, 'desc' => '每页数量'),
			),
			'charge'         => array(
				'uid'  => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'coin' => array('name' => 'coin', 'type' => 'int', 'require' => true, 'desc' => '钻石数'),
			),
			'userInfo'       => array(
				'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
			),
			
			'iftoken' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'getBaseInfo' => array(
				'uid'         => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'       => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'version_ios' => array('name' => 'version_ios', 'type' => 'string', 'desc' => 'IOS版本号'),
			),
			
			'updateAvatar' => array(
				'uid'    => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'  => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				/*'file' => array('name' => 'file','type' => 'file', 'min' => 0, 'max' => 1024 * 1024 * 30, 'range' => array('image/jpg', 'image/jpeg', 'image/png'), 'ext' => array('jpg', 'jpeg', 'png')),*/
				'avatar' => array('name' => 'avatar', 'type' => 'string', 'desc' => '用户头像地址'),
			),
			
			'updateFields' => array(
				'uid'    => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'  => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'fields' => array('name' => 'fields', 'type' => 'string', 'require' => true, 'desc' => '修改信息，json字符串'),
			),
			
			'updatePass' => array(
				'uid'     => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'   => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'oldpass' => array('name' => 'oldpass', 'type' => 'string', 'require' => true, 'desc' => '旧密码'),
				'pass'    => array('name' => 'pass', 'type' => 'string', 'require' => true, 'desc' => '新密码'),
				'pass2'   => array('name' => 'pass2', 'type' => 'string', 'require' => true, 'desc' => '确认密码'),
			),
			
			
			'getProfit' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'setCash' => array(
				'uid'       => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'     => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'accountid' => array('name' => 'accountid', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
				'cashvote'  => array('name' => 'cashvote', 'type' => 'int', 'require' => true, 'desc' => '提现的票数'),
			),
			
			'setAttent' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'isAttent' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'isBlacked'  => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			'checkBlack' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'setBlack' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'getBindCode' => array(
				'mobile' => array('name' => 'mobile', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '手机号'),
			),
			
			'setMobile' => array(
				'uid'    => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'  => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'mobile' => array('name' => 'mobile', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '手机号'),
				'code'   => array('name' => 'code', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '验证码'),
			),
			
			'getFollowsList' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'p'     => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default' => 1, 'desc' => '页数'),
			),
			
			'getFansList' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'p'     => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default' => 1, 'desc' => '页数'),
			),
			
			'getBlackList' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'p'     => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default' => 1, 'desc' => '页数'),
			),
			
			'getLiverecord' => array(
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'p'     => array('name' => 'p', 'type' => 'int', 'min' => 1, 'default' => 1, 'desc' => '页数'),
			),
			
			'getAliCdnRecord' => array(
				'id' => array('name' => 'id', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '直播记录ID'),
			),
			
			'getUserHome' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'getContributeList' => array(
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'p'     => array('name' => 'p', 'type' => 'int', 'default' => '1', 'desc' => '页数'),
			),
			
			'getPmUserInfo' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'getMultiInfo' => array(
				'uid'  => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'uids' => array('name' => 'uids', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '用户ID，多个以逗号分割'),
				'type' => array('name' => 'type', 'type' => 'int', 'require' => true, 'desc' => '关注类型，0 未关注 1 已关注'),
			),
			
			'getUidsInfo'  => array(
				'uid'  => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'uids' => array('name' => 'uids', 'type' => 'string', 'min' => 1, 'require' => true, 'desc' => '用户ID，多个以逗号分割'),
			),
			'Bonus'        => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			'getBonus'     => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			'setDistribut' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'code'  => array('name' => 'code', 'type' => 'string', 'require' => true, 'desc' => '邀请码'),
			),
			
			'getUserLabel' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'touid' => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
			),
			
			'setUserLabel' => array(
				'uid'    => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'  => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'touid'  => array('name' => 'touid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '对方ID'),
				'labels' => array('name' => 'labels', 'type' => 'string', 'require' => true, 'desc' => '印象标签ID，多个以逗号分割'),
			),
			
			'getMyLabel' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'getUserAccountList' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'setUserAccount' => array(
				'uid'          => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'        => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'type'         => array('name' => 'type', 'type' => 'int', 'require' => true, 'desc' => '账号类型，1表示支付宝，2表示微信，3表示银行卡'),
				'account_bank' => array('name' => 'account_bank', 'type' => 'string', 'default' => '', 'desc' => '银行名称'),
				'account'      => array('name' => 'account', 'type' => 'string', 'require' => true, 'desc' => '账号'),
				'name'         => array('name' => 'name', 'type' => 'string', 'default' => '', 'desc' => '姓名'),
			),
			
			'delUserAccount' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'id'    => array('name' => 'id', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
			),
			
			'setShopCash' => array(
				'uid'       => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'     => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'accountid' => array('name' => 'accountid', 'type' => 'int', 'require' => true, 'desc' => '账号ID'),
				'money'     => array('name' => 'money', 'type' => 'float', 'require' => true, 'desc' => '提现的金额'),
				'time'      => array('name' => 'time', 'type' => 'string', 'desc' => '时间戳'),
				'sign'      => array('name' => 'sign', 'type' => 'string', 'desc' => '签名字符串'),
			),
			
			'getAuthInfo' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'seeDailyTasks'     => array(
				'uid'     => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'   => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'liveuid' => array('name' => 'liveuid', 'type' => 'int', 'default' => '0', 'desc' => '主播ID'),
				'islive'  => array('name' => 'islive', 'type' => 'int', 'default' => '0', 'desc' => '是否在直播间 0不在 1在'),
			),
			'receiveTaskReward' => array(
				'uid'    => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'  => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'taskid' => array('name' => 'taskid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '任务ID'),
			),
			
			'setBeautyParams' => array(
				'uid'    => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'  => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'params' => array('name' => 'params', 'type' => 'string', 'require' => true, 'desc' => '用户设置的美颜参数'),
			),
			
			'getBeautyParams' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'getBraintreeToken' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'desc' => '用户token'),
			),
			
			'BraintreeCallback' => array(
				'uid'       => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'     => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'ordertype' => array('name' => 'ordertype', 'type' => 'string', 'require' => true, 'desc' => 'order_type 订单类型；coin_charge： 钻石充值；order_pay 商品订单支付；paidprogram_pay：付费内容'),
				'orderno'   => array('name' => 'orderno', 'type' => 'string', 'require' => true, 'desc' => '系统的订单编号'),
				'nonce'     => array('name' => 'nonce', 'type' => 'string', 'require' => true, 'desc' => 'braintree返回的三方订单编号'),
				'money'     => array('name' => 'money', 'type' => 'string', 'require' => true, 'desc' => '充值金额'),
				'time'      => array('name' => 'time', 'type' => 'string', 'desc' => '时间戳'),
				'sign'      => array('name' => 'sign', 'type' => 'string', 'desc' => '签名字符串'),
			
			),
			
			'getTurntableWinLists' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'p'     => array('name' => 'p', 'type' => 'int', 'default' => '1', 'desc' => '页数'),
			),
			
			'clearTurntableWinLists' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'checkTeenager' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'setTeenagerPassword' => array(
				'uid'      => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'    => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'password' => array('name' => 'password', 'type' => 'string', 'require' => true, 'desc' => '青少年模式密码'),
				'type'     => array('name' => 'type', 'type' => 'int', 'require' => true, 'desc' => '操作类型 0 设置密码 1开启青少年模式'),
			),
			
			'updateTeenagerPassword' => array(
				'uid'         => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'       => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'oldpassword' => array('name' => 'oldpassword', 'type' => 'string', 'require' => true, 'desc' => '青少年模式旧密码'),
				'password'    => array('name' => 'password', 'type' => 'string', 'require' => true, 'desc' => '青少年模式新密码'),
			),
			
			'closeTeenager' => array(
				'uid'      => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token'    => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'password' => array('name' => 'password', 'type' => 'string', 'require' => true, 'desc' => '青少年模式密码'),
			),
			
			'addTeenagerTime' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
			),
			
			'updateBgImg' => array(
				'uid'   => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
				'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
				'img'   => array('name' => 'img', 'type' => 'string', 'require' => true, 'desc' => '背景图'),
			),
		);
	}
	
	
	/**
	 * 判断token
	 * @desc 用于判断token
	 * @return int code 操作码，0表示成功， 1表示用户不存在
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function iftoken()
	{
		$checkToken = checkToken($this->uid, $this->token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		return $this->success();
	}
	
	/**
	 * 获取用户信息
	 * @desc 用于获取单个用户基本信息
	 * @return int code 操作码，0表示成功， 1表示用户不存在
	 * @return array info
	 * @return array info[0] 用户信息
	 * @return int info[0].id 用户ID
	 * @return string info[0].level 等级
	 * @return string info[0].lives 直播数量
	 * @return string info[0].follows 关注数
	 * @return string info[0].fans 粉丝数
	 * @return string info[0].agent_switch 分销开关
	 * @return string info[0].family_switch 家族开关
	 * @return string msg 提示信息
	 */
	public function getBaseInfo()
	{
		$rs    = array('code' => 0, 'msg' => '', 'info' => array());
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$info   = $domain->getBaseInfo($uid);
		if(empty($info)){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$configpri = getConfigPri();
		$configpub = getConfigPub();
		
		$agent_switch     = $configpri['agent_switch'];
		$family_switch    = $configpri['family_switch'];
		$service_switch   = $configpri['service_switch'];
		$service_url      = $configpri['service_url'];
		$ios_shelves      = $configpub['ios_shelves'];
		$dailytask_switch = $configpri['dailytask_switch'];
		
		//判断用户是否申请了店铺
		$shop_switch         = checkShopIsPass($uid);
		$info['shop_switch'] = $shop_switch;
		
		//判断用户是否开通了付费内容
		$info['paidprogram_switch'] = checkPaidProgramIsPass($uid);
		//商品收藏数量
		$info['goods_collect_nums'] = getGoodsCollectNums($uid);
		
		$info['isauth']        = isAuth($uid);
		$info['agent_switch']  = $agent_switch;
		$info['family_switch'] = $family_switch;
		
		/* 个人中心菜单 */
		$version_ios = $this->version_ios;
		$list        = array();
		$list1       = array();
		$list2       = array();
		$shelves     = 1;
		if($version_ios && $version_ios == $ios_shelves){
			$agent_switch  = 0;
			$family_switch = 0;
			$shelves       = 0;
		}
		
		$checkTeenager = $domain->checkTeenager($uid);
		//开启了青少年模式
		if($checkTeenager['info'][0]['is_setpassword'] == 1 && $checkTeenager['info'][0]['status'] == 1){
			$list1[] = array('id' => '23', 'name' => '动态', 'thumb' => get_upload_path("/static/appapi/images/personal/dynamic.png"), 'href' => '');
			$list1[] = array('id' => '27', 'name' => '青少年模式', 'thumb' => get_upload_path("/static/appapi/images/personal/teenager.png"), 'href' => '');
			if($service_switch && $service_url){
				$list1[] = array('id' => '21', 'name' => '在线客服', 'thumb' => get_upload_path("/static/appapi/images/personal/kefu.png"), 'href' => $service_url);
			}
			
			$list[0]['title'] = '更多服务';
			$list[0]['list']  = $list1;
		} else{
			$list1[] = array('id' => '19', 'name' => '视频', 'thumb' => get_upload_path("/static/appapi/images/personal/video.png"), 'href' => '');
			$list1[] = array('id' => '23', 'name' => '动态', 'thumb' => get_upload_path("/static/appapi/images/personal/dynamic.png"), 'href' => '');
			$list1[] = array('id' => '3', 'name' => '等级', 'thumb' => get_upload_path("/static/appapi/images/personal/level.png"), 'href' => get_upload_path("/appapi/Level/index"));
			$list1[] = array('id' => '2', 'name' => '道具', 'thumb' => get_upload_path("/static/appapi/images/personal/props.png"), 'href' => get_upload_path("/appapi/Mall/index"));
			if($shelves){
				$list1[] = array('id' => '1', 'name' => '收益', 'thumb' => get_upload_path("/static/appapi/images/personal/votes.png"), 'href' => '');
			}
			
			//转为app固定
			//$list1[]=array('id'=>'11','name'=>'认证','thumb'=>get_upload_path("/static/appapi/images/personal/auth.png") ,'href'=>get_upload_path("/appapi/Auth/index"));
			
			if($dailytask_switch){
				$list1[] = array('id' => '25', 'name' => '每日任务', 'thumb' => get_upload_path("/static/appapi/images/personal/task.png"), 'href' => '');
			}
			
			//直播小店
			$list1[] = array('id' => '22', 'name' => $configpri['shop_system_name'], 'thumb' => get_upload_path("/static/appapi/images/personal/shop.png"), 'href' => '');
			$list1[] = array('id' => '24', 'name' => '付费内容', 'thumb' => get_upload_path("/static/appapi/images/personal/pay.png"), 'href' => '');
			$list1[] = array('id' => '20', 'name' => '房间管理', 'thumb' => get_upload_path("/static/appapi/images/personal/room.png"), 'href' => '');
			if($shelves){
				$list2[] = array('id' => '5', 'name' => '装备中心', 'thumb' => get_upload_path("/static/appapi/images/personal/equipment.png"), 'href' => get_upload_path("/appapi/Equipment/index"));
			}
			if($family_switch){
				$family_status = checkUserFamily($uid);
				if($family_status == 1){ //用户创建了家族/申请加入了家族
					$family_href = '/appapi/Family/home';
				} else{
					$family_href = '/appapi/Family/index';
				}
				
				$list2[] = array('id' => '6', 'name' => '家族中心', 'thumb' => get_upload_path("/static/appapi/images/personal/family.png"), 'href' => get_upload_path($family_href));
			}
			
			if($agent_switch){
				$list2[] = array('id' => '8', 'name' => '邀请奖励', 'thumb' => get_upload_path("/static/appapi/images/personal/agent.png"), 'href' => get_upload_path("/appapi/Agent/index"));
			}
			
			$list2[] = array('id' => '26', 'name' => '中奖记录', 'thumb' => get_upload_path("/static/appapi/images/personal/turntable.png"), 'href' => '');
			$list2[] = array('id' => '27', 'name' => '青少年模式', 'thumb' => get_upload_path("/static/appapi/images/personal/teenager.png"), 'href' => '');
			if($service_switch && $service_url){
				$list2[] = array('id' => '21', 'name' => '在线客服', 'thumb' => get_upload_path("/static/appapi/images/personal/kefu.png"), 'href' => $service_url);
			}
			
			$list[0]['title'] = '我的服务';
			$list[0]['list']  = $list1;
			$list[1]['title'] = '更多服务';
			$list[1]['list']  = $list2;
		}
		
		// 整理
		$info['list'] = $list;
		
		//$rs['info'][0] = $info;
		
		return $this->success(['0' => $info]);
	}
	
	/**
	 * 个人主页
	 * @desc 用于获取个人主页数据
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].follows 关注数
	 * @return string info[0].fans 粉丝数
	 * @return string info[0].isattention 是否关注，0表示未关注，1表示已关注
	 * @return string info[0].isblack 我是否拉黑对方，0表示未拉黑，1表示已拉黑
	 * @return string info[0].isblack2 对方是否拉黑我，0表示未拉黑，1表示已拉黑
	 * @return array info[0].contribute 贡献榜前三
	 * @return array info[0].contribute[].avatar 头像
	 * @return string info[0].islive 是否正在直播，0表示未直播，1表示直播
	 * @return string info[0].videonums 视频数
	 * @return string info[0].livenums 直播数
	 * @return array info[0].liverecord 直播记录
	 * @return array info[0].label 印象标签
	 * @return string info[0].isshop 是否有店铺，0否1是
	 * @return object info[0].shop 店铺信息
	 * @return string info[0].shop.name 名称
	 * @return string info[0].shop.thumb 封面
	 * @return string info[0].shop.nums 商品数量
	 * @return string msg 提示信息
	 */
	public function getUserHome()
	{
		$uid    = checkNull($this->uid);
		$touid  = checkNull($this->touid);
		$domain = new Domain_User();
		$info   = $domain->getUserHome($uid, $touid);
		
		/* 守护 */
		$data         = array("liveuid" => $touid,);
		$domain_guard = new Domain_Guard();
		$guardlist    = $domain_guard->getGuardList($data);
		
		$info['guardlist'] = array_slice($guardlist, 0, 3);
		
		/* 标签 */
		$key   = "getMyLabel_".$touid;
		$label = getcaches($key);
		if(!$label){
			$label = $domain->getMyLabel($touid);
			setcaches($key, $label);
		}
		
		$labels = array_slice($label, 0, 3);
		
		/* 视频 */
		$domain_video      = new Domain_Video();
		$info['videolist'] = $domain_video->getHomeVideo($uid, $touid, 1);
		$info['label']     = $labels;
		
		/* 店铺 */
		$isshop = '0';
		$shop   = (object)[];
		
		$domain_shop = new Domain_Shop();
		$shopinfo    = $domain_shop->getShop($touid);
		if($shopinfo && $shopinfo['status'] == "1"){
			$isshop = '1';
			$where  = ['uid' => $touid, 'status' => 1,];
			$nums   = $domain_shop->countGoods($where);
			// 整理
			$shopinfo['nums'] = $nums;
			// 整理
			$shop = $shopinfo;
		}
		
		$info['isshop'] = $isshop;
		$info['shop']   = $shop;
		
		return $this->success(['0' => $info]);
	}
	
	// vip会员中心
	public function vip()
	{
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$nowtime    = time();
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			//return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$long     = array('1' => '1个月', '3' => '3个月', '6' => '6个月', '12' => '12个月',);
		$user     = DI()->notorm->user->select("id,user_nickname,coin,score")->where("id=?", $uid)->fetchOne();
		$vip_list = DI()->notorm->vip->order("list_order asc")->fetchAll();
		$uservip  = DI()->notorm->vip_user->where('uid=? and endtime>?', $uid, $nowtime)->fetchOne();  // 用户VIP
		if($uservip){
			$uservip['vip_txt'] = '续费';
			$uservip['endtime'] = date("Y.m.d", $uservip['endtime']);
		} else{
			$uservip['endtime'] = '';
			$uservip['vip_txt'] = '开通';
		}
		
		// 靓号
		/*$configpub  = getConfigPub();
		$liang_list = DI()->notorm->liang->where("status=0")->order("list_order asc,id desc")->limit(21)->fetchAll();
		foreach($liang_list as $k => $v){
			$liang_list[$k]['coin_date']  = number_format($v['coin']).$configpub['name_coin'];
			$liang_list[$k]['score_date'] = number_format($v['score']).$configpub['name_score'];
		}*/
		
		//  坐骑
		$car_key  = 'carinfo';
		$car_list = getcaches($car_key);
		if(!$car_list){
			$car_list = DI()->notorm->car->order("list_order asc")->fetchAll();
			if($car_list){
				setcaches($car_key, $car_list);
			}
		}
		foreach($car_list as $k => $v){
			$car_list[$k]['thumb'] = get_upload_path($v['thumb']);
			$car_list[$k]['swf']   = get_upload_path($v['swf']);
		}
		// 'liang_list' => $liang_list
		$result = ['car_list' => $car_list, 'uservip' => $uservip, 'vip_list' => $vip_list, 'user' => $user, 'long' => $long];
		
		return $this->success($result);
	}
	
	############################################################################################################
	
	/**
	 * 获取找回密码短信验证码
	 * @desc 用于找回密码获取短信验证码
	 * @return int code 操作码，0表示成功,2发送失败
	 * @return array info
	 * @return array info[0]
	 * @return string msg 提示信息
	 */
	public function getBindCode()
	{
		$mobile   = checkNull($this->mobile);
		$ismobile = checkMobile($mobile);
		if(!$ismobile){
			return $this->fail('请输入正确的手机号!', 1001);
		}
		if($_SESSION['set_mobile'] == $mobile && $_SESSION['set_mobile_expiretime'] > time()){
			return $this->fail('验证码5分钟有效，请勿多次发送!', 1002);
		}
		
		$mobile_code = random(6, 1);
		/* 发送验证码 */
		$result = sendCode(86, $mobile, $mobile_code);
		if($result['code'] === 0){
			$_SESSION['set_mobile']            = $mobile;
			$_SESSION['set_mobile_code']       = $mobile_code;
			$_SESSION['set_mobile_expiretime'] = time() + 60 * 5;
		} elseif($result['code'] == 667){
			$_SESSION['set_mobile']            = $mobile;
			$_SESSION['set_mobile_code']       = $result['msg'];
			$_SESSION['set_mobile_expiretime'] = time() + 60 * 5;
			
			$msg = '验证码为：'.$result['msg'];
		} else{
			$msg = $result['msg'];
		}
		
		return $this->fail($msg, 1002);
	}
	
	/**
	 * 绑定手机号
	 * @desc 用于用户绑定手机号
	 * @return int code 操作码，0表示成功，非0表示有错误
	 * @return array info
	 * @return object info[0].msg 绑定成功提示
	 * @return string msg 提示信息
	 */
	public function setMobile()
	{
		
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid    = checkNull($this->uid);
		$token  = checkNull($this->token);
		$mobile = checkNull($this->mobile);
		$code   = checkNull($this->code);
		if($mobile != $_SESSION['set_mobile']){
			return $this->fail('手机号码不一致!', 1001);
		}
		if($code != $_SESSION['set_mobile_code']){
			return $this->fail('验证码错误!', 1002);
		}
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		//更新数据库
		$data   = array("mobile" => $mobile);
		$result = $domain->userUpdate($uid, $data);
		if($result === false){
			return $this->fail('绑定失败!', 1003);
		}
		
		//return $this->success([],'绑定成功!');
		//$rs['info'][0]['msg'] = '绑定成功';
		
		
		return $this->success(['0' => ['msg' => '绑定成功!']], '绑定成功！');
	}
	
	/**
	 * 关注列表
	 * @desc 用于获取用户的关注列表
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].isattent 是否关注,0表示未关注，1表示已关注
	 * @return string msg 提示信息
	 */
	public function getFollowsList()
	{
		$uid    = checkNull($this->uid);
		$touid  = checkNull($this->touid);
		$p      = checkNull($this->p);
		$domain = new Domain_User();
		$info   = $domain->getFollowsList($uid, $touid, $p);
		
		return $this->success($info);
	}
	
	/**
	 * 粉丝列表
	 * @desc 用于获取用户的粉丝列表
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].isattent 是否关注,0表示未关注，1表示已关注
	 * @return string msg 提示信息
	 */
	public function getFansList()
	{
		$uid    = checkNull($this->uid);
		$touid  = checkNull($this->touid);
		$p      = checkNull($this->p);
		$domain = new Domain_User();
		$info   = $domain->getFansList($uid, $touid, $p);
		
		return $this->success($info);
	}
	
	/**
	 * 黑名单列表
	 * @desc 用于获取用户的黑名单列表
	 * @return int code 操作码，0表示成功
	 * @return array info 用户基本信息
	 * @return string msg 提示信息
	 */
	public function getBlackList()
	{
		$uid    = checkNull($this->uid);
		$touid  = checkNull($this->touid);
		$p      = checkNull($this->p);
		$domain = new Domain_User();
		$info   = $domain->getBlackList($uid, $touid, $p);
		
		return $this->success($info);
	}
	
	/**
	 * 直播记录
	 * @desc 用于获取用户的直播记录
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].nums 观看人数
	 * @return string info[].datestarttime 格式化的开播时间
	 * @return string info[].dateendtime 格式化的结束时间
	 * @return string info[].video_url 回放地址
	 * @return string info[].file_id 回放标示
	 * @return string msg 提示信息
	 */
	public function getLiverecord()
	{
		$touid  = checkNull($this->touid);
		$p      = checkNull($this->p);
		$domain = new Domain_User();
		$info   = $domain->getLiverecord($touid, $p);
		
		return $this->success($info);
	}
	
	/**
	 *获取阿里云cdn录播地址
	 * @desc 如果使用的阿里云cdn，则使用该接口获取录播地址
	 * @return int code 操作码，0表示成功
	 * @return string info[0].url 录播视频地址
	 * @return string msg 提示信息
	 */
	public function getAliCdnRecord()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$id     = checkNull($this->id);
		$domain = new Domain_Cdnrecord();
		$info   = $domain->getCdnRecord($id);
		if(!$info['video_url']){
			return $this->fail('直播回放不存在!', 1002);
		}
		
		$rs['info'][0]['url'] = $info['video_url'];
		
		return $rs;
	}
	
	############################################################################################################
	## 未整理
	
	/**
	 * 贡献榜
	 * @desc 用于获取贡献榜
	 * @return int code 操作码，0表示成功
	 * @return array info 排行榜列表
	 * @return string info[].total 贡献总数
	 * @return string info[].userinfo 用户信息
	 * @return string msg 提示信息
	 */
	public function getContributeList()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$touid  = checkNull($this->touid);
		$p      = checkNull($this->p);
		$domain = new Domain_User();
		$info   = $domain->getContributeList($touid, $p);
		
		$rs['info'] = $info;
		
		return $rs;
	}
	
	/**
	 * 私信用户信息
	 * @desc 用于获取其他用户基本信息
	 * @return int code 操作码，0表示成功，1表示用户不存在
	 * @return array info
	 * @return string info[0].id 用户ID
	 * @return string info[0].isattention 我是否关注对方，0未关注，1已关注
	 * @return string info[0].isattention2 对方是否关注我，0未关注，1已关注
	 * @return string msg 提示信息
	 */
	public function getPmUserInfo()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$touid = checkNull($this->touid);
		$info  = getUserInfo($touid);
		if(empty($info)){
			$rs['code'] = 1001;
			$rs['msg']  = '用户不存在';
			
			return $rs;
		}
		$info['isattention2'] = (string)isAttention($touid, $uid);
		$info['isattention']  = (string)isAttention($uid, $touid);
		// 合并
		$rs['info'][0] = $info;
		
		return $rs;
	}
	
	/**
	 * 获取多用户信息
	 * @desc 用于获取获取多用户信息
	 * @return int code 操作码，0表示成功
	 * @return array info 排行榜列表
	 * @return string info[].utot 是否关注，0未关注，1已关注
	 * @return string info[].ttou 对方是否关注我，0未关注，1已关注
	 * @return string msg 提示信息
	 */
	public function getMultiInfo()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid  = checkNull($this->uid);
		$uids = checkNull($this->uids);
		$type = checkNull($this->type);
		
		$configpri = getConfigPri();
		if($configpri['letter_switch'] != 1){
			return $rs;
		}
		
		$uids = explode(",", $uids);
		foreach($uids as $k => $userId){
			if($userId){
				$userinfo = getUserInfo($userId);
				if($userinfo){
					$userinfo['utot'] = isAttention($uid, $userId);
					$userinfo['ttou'] = isAttention($userId, $uid);
					// 合并
					if($userinfo['utot'] == $type){
						$rs['info'][] = $userinfo;
					}
				}
			}
		}
		
		return $rs;
	}
	
	/**
	 * 获取多用户信息(不区分是否关注)
	 * @desc 用于获取多用户信息
	 * @return int code 操作码，0表示成功
	 * @return array info 排行榜列表
	 * @return string info[].utot 是否关注，0未关注，1已关注
	 * @return string info[].ttou 对方是否关注我，0未关注，1已关注
	 * @return string msg 提示信息
	 */
	public function getUidsInfo()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid  = checkNull($this->uid);
		$uids = checkNull($this->uids);
		$uids = explode(",", $uids);
		foreach($uids as $k => $userId){
			if($userId){
				$userinfo = getUserInfo($userId);
				if($userinfo){
					$userinfo['utot'] = isAttention($uid, $userId);
					$userinfo['ttou'] = isAttention($userId, $uid);
					// 合并
					$rs['info'][] = $userinfo;
				}
			}
		}
		
		return $rs;
	}
	
	/**
	 * 登录奖励
	 * @desc 用于用户登录奖励
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].bonus_switch 登录开关，0表示未开启
	 * @return string info[0].bonus_day 登录天数,0表示已奖励
	 * @return string info[0].count_day 连续登陆天数
	 * @return string info[0].bonus_list 登录奖励列表
	 * @return string info[0].bonus_list[].day 登录天数
	 * @return string info[0].bonus_list[].coin 登录奖励
	 * @return string msg 提示信息
	 */
	public function Bonus()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		$domain = new Domain_User();
		$info   = $domain->LoginBonus($uid);
		
		$rs['info'][0] = $info;
		
		return $rs;
	}
	
	/**
	 * 登录奖励
	 * @desc 用于用户登录奖励
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].bonus_switch 登录开关，0表示未开启
	 * @return string info[0].bonus_day 登录天数,0表示已奖励
	 * @return string msg 提示信息
	 */
	public function getBonus()
	{
		$rs = array('code' => 0, 'msg' => '领取成功', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		$domain = new Domain_User();
		$info   = $domain->getLoginBonus($uid);
		if(!$info){
			$rs['code'] = 1001;
			$rs['msg']  = '领取失败';
			
			return $rs;
		}
		
		return $rs;
	}
	
	/**
	 * 设置分销上级
	 * @desc 用于用户首次登录设置分销关系
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].msg 提示信息
	 * @return string msg 提示信息
	 */
	public function setDistribut()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		$code  = checkNull($this->code);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		if($code == ''){
			$rs['code'] = 1001;
			$rs['msg']  = '请输入邀请码';
			
			return $rs;
		}
		
		$domain = new Domain_User();
		$info   = $domain->setDistribut($uid, $code);
		if($info == 1004){
			$rs['code'] = 1004;
			$rs['msg']  = '已设置，不能更改';
			
			return $rs;
		}
		if($info == 1002){
			$rs['code'] = 1002;
			$rs['msg']  = '邀请码错误';
			
			return $rs;
		}
		if($info == 1003){
			$rs['code'] = 1003;
			$rs['msg']  = '不能填写自己下级的邀请码';
			
			return $rs;
		}
		
		$rs['info'][0]['msg'] = '设置成功';
		
		return $rs;
	}
	
	/**
	 * 获取用户间印象标签
	 * @desc 用于获取用户间印象标签
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].id 标签ID
	 * @return string info[].name 名称
	 * @return string info[].colour 色值
	 * @return string info[].ifcheck 是否选择
	 * @return string msg 提示信息
	 */
	public function getUserLabel()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$touid = checkNull($this->touid);
		$key   = "getUserLabel_".$uid.'_'.$touid;
		$label = getcaches($key);
		
		if(!$label){
			$domain = new Domain_User();
			$info   = $domain->getUserLabel($uid, $touid);
			$label  = $info['label'];
			setcaches($key, $label);
		}
		
		$label_check = preg_split('/,|，/', $label);
		$label_check = array_filter($label_check);
		$label_check = array_values($label_check);
		
		
		$key2       = "getImpressionLabel";
		$label_list = getcaches($key2);
		if(!$label_list){
			$domain     = new Domain_User();
			$label_list = $domain->getImpressionLabel();
		}
		foreach($label_list as $k => $v){
			$ifcheck = '0';
			if(in_array($v['id'], $label_check)){
				$ifcheck = '1';
			}
			$label_list[$k]['ifcheck'] = $ifcheck;
		}
		
		$rs['info'] = $label_list;
		
		return $rs;
	}
	
	/**
	 * 获取用户间印象标签
	 * @desc 用于获取用户间印象标签
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].id 标签ID
	 * @return string info[].name 名称
	 * @return string info[].colour 色值
	 * @return string msg 提示信息
	 */
	public function setUserLabel()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid    = checkNull($this->uid);
		$token  = checkNull($this->token);
		$touid  = checkNull($this->touid);
		$labels = checkNull($this->labels);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		if($uid == $touid){
			$rs['code'] = 1003;
			$rs['msg']  = '不能给自己设置标签';
			
			return $rs;
		}
		if($labels == ''){
			$rs['code'] = 1001;
			$rs['msg']  = '请选择印象';
			
			return $rs;
		}
		
		$labels_a = preg_split('/,|，/', $labels);
		$labels_a = array_filter($labels_a);
		$nums     = count($labels_a);
		if($nums > 3){
			$rs['code'] = 1002;
			$rs['msg']  = '最多只能选择3个印象';
			
			return $rs;
		}
		
		
		$domain = new Domain_User();
		$result = $domain->setUserLabel($uid, $touid, $labels);
		if($result){
			$key = "getUserLabel_".$uid.'_'.$touid;
			setcaches($key, $labels);
			
			$key2 = "getMyLabel_".$touid;
			delcache($key2);
		}
		
		$rs['msg'] = '设置成功';
		
		return $rs;
	}
	
	/**
	 * 获取自己所有的印象标签
	 * @desc 用于获取自己所有的印象标签
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].id 标签ID
	 * @return string info[].name 名称
	 * @return string info[].colour 色值
	 * @return string info[].nums 数量
	 * @return string msg 提示信息
	 */
	public function getMyLabel()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$key  = "getMyLabel_".$uid;
		$info = getcaches($key);
		if(!$info){
			$domain = new Domain_User();
			$info   = $domain->getMyLabel($uid);
			setcaches($key, $info);
		}
		
		$rs['info'] = $info;
		
		return $rs;
	}
	
	############################################################################################################
	
	/**
	 * 判断是否关注
	 * @desc 用于判断是否关注
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].isattent 关注信息，0表示未关注，1表示已关注
	 * @return string msg 提示信息
	 */
	public function isAttent()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$touid = checkNull($this->touid);
		$info  = isAttention($uid, $touid);
		
		// 整理
		//return $this->success(['0' => ['isattent' => (string)$info]]);
		$rs['info'][0]['isattent'] = (string)$info;
		
		return $rs;
	}
	
	/**
	 * 关注/取消关注
	 * @desc 用于关注/取消关注
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].isattent 关注信息，0表示未关注，1表示已关注
	 * @return string msg 提示信息
	 */
	public function setAttent()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$touid = checkNull($this->touid);
		if($uid == $touid){
			return $this->fail('不能关注自己！', 1001);
		}
		
		$domain = new Domain_User();
		$info   = $domain->setAttent($uid, $touid);
		
		// 整理
		//return $this->success(['0' => ['isattent' => (string)$info]]);
		$rs['info'][0]['isattent'] = (string)$info;
		
		return $rs;
	}
	
	/**
	 * 判断是否拉黑
	 * @desc 用于判断是否拉黑
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].isattent  拉黑信息,0表示未拉黑，1表示已拉黑
	 * @return string msg 提示信息
	 */
	public function isBlacked()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$touid = checkNull($this->touid);
		$info  = isBlack($uid, $touid);
		
		// 整理
		//return $this->success(['0' => ['isblack' => (string)$info]]);
		$rs['info'][0]['isblack'] = (string)$info;
		
		return $rs;
	}
	
	/**
	 * 检测拉黑状态
	 * @desc 用于私信聊天时判断私聊双方的拉黑状态
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].u2t  是否拉黑对方,0表示未拉黑，1表示已拉黑
	 * @return string info[0].t2u  是否被对方拉黑,0表示未拉黑，1表示已拉黑
	 * @return string msg 提示信息
	 */
	public function checkBlack()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$touid = checkNull($this->touid);
		//判断对方是否已注销
		$is_destroy = checkIsDestroyByUid($touid);
		if($is_destroy){
			return $this->fail('对方已注销！', 1001);
		}
		
		$u2t = isBlack($uid, $touid);
		$t2u = isBlack($touid, $uid);
		
		// 整理
		//return $this->success(['0' => ['u2t' => (string)$u2t, 't2u' => (string)$t2u]]);
		$rs['info'][0]['u2t'] = (string)$u2t;
		$rs['info'][0]['t2u'] = (string)$t2u;
		
		return $rs;
	}
	
	/**
	 * 拉黑/取消拉黑
	 * @desc 用于拉黑/取消拉黑
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].isblack 拉黑信息,0表示未拉黑，1表示已拉黑
	 * @return string msg 提示信息
	 */
	public function setBlack()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid    = checkNull($this->uid);
		$touid  = checkNull($this->touid);
		$domain = new Domain_User();
		$info   = $domain->setBlack($uid, $touid);
		
		// 整理
		//return $this->success(['0' => ['isblack' => (string)$info]]);
		$rs['info'][0]['isblack'] = (string)$info;
		
		return $rs;
	}
	
	
	/**
	 * 举报类型
	 * @desc 用于获取举报类型
	 * @return int code 操作码，0表示成功
	 * @return array info 列表
	 * @return string info[].name 类型名称
	 * @return string msg 提示信息
	 */
	public function getReportClass()
	{
		$domain = new Domain_Live();
		$info   = $domain->getReportClass();
		
		return $this->success($info);
	}
	
	
	/**
	 * 用户举报
	 * @desc 用于用户举报
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].msg 举报成功
	 * @return string msg 提示信息
	 */
	public function setReport()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid     = checkNull($this->uid);
		$token   = checkNull($this->token);
		$touid   = checkNull($this->touid);
		$content = checkNull($this->content);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		if(!$content){
			return $this->fail('举报内容不能为空！', 1001);
		}
		
		$domain = new Domain_Live();
		$info   = $domain->setReport($uid, $touid, $content);
		if($info === false){
			return $this->fail('举报失败，请重试！', 1002);
		}
		
		// 整理
		//$rs['info'][0]['msg'] = "举报成功";
		
		return $this->success(['0' => ['msg' => '举报成功!']], '举报成功！');
	}
	
	############################################################################################################
	
	/**
	 * 我的收益
	 * @desc 用于获取用户收益，包括可体现金额，今日可提现金额
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].votes 可提取映票数
	 * @return string info[0].votestotal 总映票
	 * @return string info[0].cash_rate 映票兑换比例
	 * @return string info[0].total 可提现金额
	 * @return string info[0].tips 温馨提示
	 * @return string msg 提示信息
	 */
	public function getProfit()
	{
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$info   = $domain->getProfit($uid);
		
		return $this->success(['0' => $info]);
	}
	
	/**
	 * 用户提现
	 * @desc 用于进行用户提现
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].msg 提现成功信息
	 * @return string msg 提示信息
	 */
	public function setCash()
	{
		$rs = array('code' => 0, 'msg' => '提现成功', 'info' => array());
		//暂时屏蔽提现功能
		$rs['code'] = 1005;
		$rs['msg']  = '不在提现期限内，不能提现';
		
		return $rs;
		
		$uid       = checkNull($this->uid);
		$token     = checkNull($this->token);
		$accountid = checkNull($this->accountid);
		$cashvote  = checkNull($this->cashvote);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		if(!$accountid){
			$rs['code'] = 1001;
			$rs['msg']  = '请选择提现账号';
			
			return $rs;
		}
		
		if(!$cashvote){
			$rs['code'] = 1002;
			$rs['msg']  = '请输入有效的提现票数';
			
			return $rs;
		}
		
		$data   = array(
			'uid'       => $uid,
			'accountid' => $accountid,
			'cashvote'  => $cashvote,
		);
		$config = getConfigPri();
		$domain = new Domain_User();
		$info   = $domain->setCash($data);
		if($info == 1001){
			$rs['code'] = 1001;
			$rs['msg']  = '您输入的金额大于可提现金额';
			
			return $rs;
		} elseif($info == 1003){
			$rs['code'] = 1003;
			$rs['msg']  = '请先进行身份认证';
			
			return $rs;
		} elseif($info == 1004){
			$rs['code'] = 1004;
			$rs['msg']  = '提现最低额度为'.$config['cash_min'].'元';
			
			return $rs;
		} elseif($info == 1005){
			$rs['code'] = 1005;
			$rs['msg']  = '不在提现期限内，不能提现';
			
			return $rs;
		} elseif($info == 1006){
			$rs['code'] = 1006;
			$rs['msg']  = '每月只可提现'.$config['cash_max_times'].'次,已达上限';
			
			return $rs;
		} elseif($info == 1007){
			$rs['code'] = 1007;
			$rs['msg']  = '提现账号信息不正确';
			
			return $rs;
		} elseif(!$info){
			$rs['code'] = 1002;
			$rs['msg']  = '提现失败，请重试';
			
			return $rs;
		}
		
		$rs['info'][0]['msg'] = '提现成功';
		
		return $rs;
	}
	
	/**
	 * 头像上传
	 * @desc 用于用户修改头像
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string list[0].avatar 用户主头像
	 * @return string list[0].avatar_thumb 用户头像缩略图
	 * @return string msg 提示信息
	 */
	public function updateAvatar()
	{
		$uid        = checkNull($this->uid);
		$token      = checkNull($this->token);
		$avatar_str = checkNull($this->avatar);
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		//APP原生上传存储到数据库start
		if(!$avatar_str){
			return $this->fail('请上传头像！', 1001);
		}
		
		$configpri = getConfigPri();
		$cloudtype = $configpri['cloudtype'];
		if($cloudtype == 1){ //七牛云存储
			$avatar       = $avatar_str.'?imageView2/2/w/600/h/600'; //600 X 600
			$avatar_thumb = $avatar_str.'?imageView2/2/w/200/h/200'; // 200 X 200
		} else{ //亚马逊存储
			$avatar       = $avatar_str;
			$avatar_thumb = $avatar_str;
		}
		$data  = array("avatar" => get_upload_path($avatar), "avatar_thumb" => get_upload_path($avatar_thumb),);
		$data2 = array("avatar" => $avatar, "avatar_thumb" => $avatar_thumb,);
		
		//APP原生上传存储到数据库end
		//接口获取文件上传 存储到数据库start
		/*if (!isset($_FILES['file'])) {
			$rs['code'] = 1001;
			$rs['msg'] = "请选择上传文件";
			return $rs;
		}
		if ($_FILES["file"]["error"] > 0) {
			$rs['code'] = 1002;
			$rs['msg']='上传失败'.$_FILES["file"]["error"];
			//$rs['msg'] = T('failed to upload file with error: {error}', array('error' => $_FILES['file']['error']));
			DI()->logger->debug('failed to upload file with error: ' . $_FILES['file']['error']);
			return $rs;
		}
		$uptype=DI()->config->get('app.uptype');

		if($uptype==1){
			//七牛
			$url = DI()->qiniu->uploadFile($_FILES['file']['tmp_name']);

			if (!empty($url)) {
				$avatar=  $url.'?imageView2/2/w/600/h/600'; //600 X 600
				$avatar_thumb=  $url.'?imageView2/2/w/200/h/200'; // 200 X 200
				$data=array(
					"avatar"=>$avatar,
					"avatar_thumb"=>$avatar_thumb,
				);
                
                $data2=array(
					"avatar"=>$avatar,
					"avatar_thumb"=>$avatar_thumb,
				);

				
				// 统一服务器 格式
				// $space_host= DI()->config->get('app.Qiniu.space_host');
				// $avatar2=str_replace($space_host.'/', "", $avatar);
				// $avatar_thumb2=str_replace($space_host.'/', "", $avatar_thumb);
				// $data2=array(
				// 	"avatar"=>$avatar2,
				// 	"avatar_thumb"=>$avatar_thumb2,
				// );
			}
		}else if($uptype==2){
			//本地上传
			//设置上传路径 设置方法参考3.2
			DI()->ucloud->set('save_path','avatar/'.date("Ymd"));

			//新增修改文件名设置上传的文件名称
		   // DI()->ucloud->set('file_name', $this->uid);

			//上传表单名
			$res = DI()->ucloud->upfile($_FILES['file']);
			
			$files='../upload'.$res['file'];
			$newfiles=str_replace(".png","_thumb.png",$files);
			$newfiles=str_replace(".jpg","_thumb.jpg",$newfiles);
			$newfiles=str_replace(".gif","_thumb.gif",$newfiles);
			$PhalApi_Image = new Image_Lite();
			//打开图片
			$PhalApi_Image->open($files);
			
			 //可以支持其他类型的缩略图生成，设置包括下列常量或者对应的数字：
			 // IMAGE_THUMB_SCALING      //常量，标识缩略图等比例缩放类型
			 // IMAGE_THUMB_FILLED       //常量，标识缩略图缩放后填充类型
			 // IMAGE_THUMB_CENTER       //常量，标识缩略图居中裁剪类型
			 // IMAGE_THUMB_NORTHWEST    //常量，标识缩略图左上角裁剪类型
			 // IMAGE_THUMB_SOUTHEAST    //常量，标识缩略图右下角裁剪类型
			 // IMAGE_THUMB_FIXED        //常量，标识缩略图固定尺寸缩放类型
			 

			// 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg
			
			$PhalApi_Image->thumb(660, 660, IMAGE_THUMB_SCALING);
			$PhalApi_Image->save($files);

			$PhalApi_Image->thumb(200, 200, IMAGE_THUMB_SCALING);
			$PhalApi_Image->save($newfiles);
			
			$avatar=  '/upload'.$res['file']; //600 X 600
			
			$avatar_thumb=str_replace(".png","_thumb.png",$avatar);
			$avatar_thumb=str_replace(".jpg","_thumb.jpg",$avatar_thumb);
			$avatar_thumb=str_replace(".gif","_thumb.gif",$avatar_thumb);

			$data=array(
				"avatar"=>get_upload_path($avatar),
				"avatar_thumb"=>get_upload_path($avatar_thumb),
			);
            
            $data2=array(
				"avatar"=>$avatar,
				"avatar_thumb"=>$avatar_thumb,
			);
			
		}
		
		@unlink($_FILES['file']['tmp_name']);
        if(!$data){
            $rs['code'] = 1003;
			$rs['msg'] = '更换失败，请稍候重试';
			return $rs;
        }*/
		
		//接口获取文件上传 存储到数据库end
		
		// 清除缓存
		delCache("userinfo_".$uid);
		
		$domain = new Domain_User();
		$info   = $domain->userUpdate($uid, $data2);
		
		return $this->success(['0' => $data], '设置头像成功！');
	}
	
	/**
	 * 修改用户信息
	 * @desc 用于修改用户信息
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string list[0].msg 修改成功提示信息
	 * @return string msg 提示信息
	 */
	public function updateFields()
	{
		$rs = array('code' => 0, 'msg' => '修改成功', 'info' => array());
		
		$checkToken = checkToken($this->uid, $this->token);
		if($checkToken == 700){
			//return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$fields = json_decode($this->fields, true);
		$allow  = ['user_nickname', 'sex', 'signature', 'birthday', 'location'];
		$domain = new Domain_User();
		foreach($fields as $k => $v){
			if(in_array($k, $allow)){
				$fields[$k] = checkNull($v);
			} else{
				unset($fields[$k]);
			}
		}
		
		if(array_key_exists('user_nickname', $fields)){
			if($fields['user_nickname'] == ''){
				return $this->fail('昵称不能为空！', 1002);
			}
			if(strstr($fields['user_nickname'], '已注销') !== false){ //昵称包含已注销三个字
				return $this->fail('输入非法，请重新输入！', 10011);
			}
			if(mb_substr($fields['user_nickname'], 0, 1) == '='){
				return $this->fail('输入非法，请重新输入！', 10011);
			}
			
			$isexist = $domain->checkName($this->uid, $fields['user_nickname']);
			if(!$isexist){
				return $this->fail('昵称重复，请修改！', 1002);
			}
			
			//$fields['user_nickname']=filterField($fields['user_nickname']);
			$sensitivewords = sensitiveField($fields['user_nickname']);
			if($sensitivewords == 1001){
				return $this->fail('输入非法，请重新输入！', 10011);
			}
		}
		if(array_key_exists('signature', $fields)){
			$sensitivewords = sensitiveField($fields['signature']);
			if($sensitivewords == 1001){
				return $this->fail('输入非法，请重新输入！', 10011);
			}
		}
		
		if(array_key_exists('birthday', $fields)){
			$fields['birthday'] = strtotime($fields['birthday']);
		}
		
		$info = $domain->userUpdate($this->uid, $fields);
		if($info === false){
			return $this->fail('修改失败！', 1001);
		}
		/* 清除缓存 */
		delCache("userinfo_".$this->uid);
		
		//$rs['info'][0]['msg'] = '修改成功';
		
		return $this->success(['0' => ['msg' => '修改成功!']], '修改成功！');
	}
	
	/**
	 * 修改密码
	 * @desc 用于修改用户密码
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string list[0].msg 修改成功提示信息
	 * @return string msg 提示信息
	 */
	public function updatePass()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid     = checkNull($this->uid);
		$token   = checkNull($this->token);
		$oldpass = checkNull($this->oldpass);
		$pass    = checkNull($this->pass);
		$pass2   = checkNull($this->pass2);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		if($pass != $pass2){
			return $this->fail('两次新密码不一致！', 1002);
		}
		
		$check = passcheck($pass);
		if(!$check){
			return $this->fail('密码为6-20位字母数字组合！', 1004);
		}
		
		$domain = new Domain_User();
		$info   = $domain->updatePass($uid, $oldpass, $pass);
		if($info == 1003){
			return $this->fail('旧密码错误！', 1003);
		} elseif($info === false){
			return $this->fail('修改失败！', 1001);
		}
		
		//$rs['info'][0]['msg'] = '修改成功';
		
		return $this->success(['0' => ['msg' => '修改成功!']], '修改成功！');
	}
	
	
	############################################################################################################
	## 设置
	/**
	 * 获取个性设置列表
	 * @desc 用于获取个性设置列表
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function getPerSetting()
	{
		$domain = new Domain_User();
		$info   = $domain->getPerSetting();
		
		$info[] = array('id' => '17', 'show_id' => '17', 'name' => '意见反馈', 'thumb' => '', 'href' => get_upload_path('/appapi/feedback/index'));
		$info[] = array('id' => '15', 'show_id' => '15', 'name' => '修改密码', 'thumb' => '', 'href' => '');
		$info[] = array('id' => '18', 'show_id' => '18', 'name' => '清除缓存', 'thumb' => '', 'href' => '');
		$info[] = array('id' => '19', 'show_id' => '19', 'name' => '注销账号', 'thumb' => '', 'href' => get_upload_path('/portal/page/index?id=44'));
		$info[] = array('id' => '16', 'show_id' => '16', 'name' => '检查更新', 'thumb' => '', 'href' => '');
		
		return $this->success($info);
	}
	
	// 获取配置详情信息
	public function getShowSetting()
	{
		$id     = checkNull($this->id);
		$domain = new Domain_User();
		$info   = $domain->getShowSetting($id);
		
		return $this->success(['0' => $info]);
	}
	
	// 意见反馈
	public function feedback()
	{
		$uid     = checkNull($this->uid);
		$token   = checkNull($this->token);
		$version = checkNull($this->version);
		$model   = checkNull($this->model);
		$content = checkNull($this->content);
		$thumb   = checkNull($this->thumb);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$configpri = getConfigPri();
		$cloudtype = $configpri['cloudtype'];
		if($cloudtype == 1){ //七牛云存储
			$thumb = $thumb.'?imageView2/2/w/600/h/600'; //600 X 600
		} else{ //亚马逊存储
			//$thumb = $thumb;
		}
		
		$data   = ['uid' => $uid, 'version' => $version, 'model' => $model, 'content' => $content, 'thumb' => get_upload_path($thumb), 'addtime' => time(),];
		$domain = new Domain_User();
		$res    = $domain->feedback($data);
		
		return $this->success();
	}
	
	############################################################################################################
	## 我的钻石
	
	/**
	 * 我的钻石
	 * @desc 用于获取用户余额,充值规则 支付方式信息
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[0].coin 用户钻石余额
	 * @return array info[0].rules 充值规则
	 * @return string info[0].rules[].id 充值规则
	 * @return string info[0].rules[].coin 钻石
	 * @return string info[0].rules[].money 价格
	 * @return string info[0].rules[].money_ios 苹果充值价格
	 * @return string info[0].rules[].product_id 苹果项目ID
	 * @return string info[0].rules[].give 赠送钻石，为0时不显示赠送
	 * @return string info[0].aliapp_switch 支付宝开关，0表示关闭，1表示开启
	 * @return string info[0].aliapp_partner 支付宝合作者身份ID
	 * @return string info[0].aliapp_seller_id 支付宝帐号
	 * @return string info[0].aliapp_key_android 支付宝安卓密钥
	 * @return string info[0].aliapp_key_ios 支付宝苹果密钥
	 * @return string info[0].wx_switch 微信支付开关，0表示关闭，1表示开启
	 * @return string info[0].wx_appid 开放平台账号AppID
	 * @return string info[0].wx_appsecret 微信应用appsecret
	 * @return string info[0].wx_mchid 微信商户号mchid
	 * @return string info[0].wx_key 微信密钥key
	 * @return string msg 提示信息
	 */
	public function getBalance()
	{
		$uid         = checkNull($this->uid);
		$token       = checkNull($this->token);
		$type        = checkNull($this->type);
		$version_ios = checkNull($this->version_ios);
		$checkToken  = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$info   = $domain->getBalance($uid);
		$key    = 'getChargeRules';
		$rules  = getcaches($key);
		if(!$rules){
			$rules = $domain->getChargeRules();
			setcaches($key, $rules);
		}
		$info['rules'] = $rules;
		
		$configpub = getConfigPub();
		$configpri = getConfigPri();
		
		$aliapp_switch = $configpri['aliapp_switch'];
		
		$info['aliapp_switch']      = $aliapp_switch;
		$info['aliapp_partner']     = $aliapp_switch == 1 ? $configpri['aliapp_partner'] : '';
		$info['aliapp_seller_id']   = $aliapp_switch == 1 ? $configpri['aliapp_seller_id'] : '';
		$info['aliapp_key_android'] = $aliapp_switch == 1 ? $configpri['aliapp_key_android'] : '';
		$info['aliapp_key_ios']     = $aliapp_switch == 1 ? $configpri['aliapp_key_ios'] : '';
		
		$wx_switch            = $configpri['wx_switch'];
		$info['wx_switch']    = $wx_switch;
		$info['wx_appid']     = $wx_switch == 1 ? $configpri['wx_appid'] : '';
		$info['wx_appsecret'] = $wx_switch == 1 ? $configpri['wx_appsecret'] : '';
		$info['wx_mchid']     = $wx_switch == 1 ? $configpri['wx_mchid'] : '';
		$info['wx_key']       = $wx_switch == 1 ? $configpri['wx_key'] : '';
		
		/*【原Paypal支付因无法使用已废弃】
		$paypal_switch=$configpri['paypal_switch'];
		$info['paypal_switch']=$paypal_switch;
		$info['paypal_sandbox']=$configpri['paypal_sandbox'];
		$info['sandbox_clientid']=$configpri['sandbox_clientid'];//Paypal支付沙盒客户端ID
		$info['product_clientid']=$configpri['product_clientid'];//Paypal支付生产客户端ID
		*/
		
		$braintree_paypal_switch = $configpri['braintree_paypal_switch'];
		$wx_mini_switch          = $configpri['wx_mini_switch'];
		$info['wx_mini_switch']  = $wx_mini_switch;
		
		/* 支付列表 */
		$shelves     = 1;
		$ios_shelves = $configpub['ios_shelves'];
		if($version_ios && $version_ios == $ios_shelves){
			$shelves = 0;
		}
		
		$paylist = [];
		if($aliapp_switch && $shelves){
			$paylist[] = [
				'id'    => 'ali',
				'name'  => '支付宝支付',
				'thumb' => get_upload_path("/static/app/pay/ali.png"),
				'href'  => '',
			];
		}
		
		if($wx_switch && $shelves){
			$paylist[] = [
				'id'    => 'wx',
				'name'  => '微信支付',
				'thumb' => get_upload_path("/static/app/pay/wx.png"),
				'href'  => '',
			];
		}
		
		/*【原Paypal支付因无法使用已废弃】
		if($paypal_switch && $shelves){
			$paylist[]=[
				'id'=>'paypal',
				'name'=>'Paypal支付',
				'thumb'=>get_upload_path("/static/app/pay/paypal.png"),
				'href'=>'',
			];
		}*/
		
		if($braintree_paypal_switch && $shelves){
			$paylist[] = [
				'id'    => 'paypal',
				'name'  => 'Paypal支付',
				'thumb' => get_upload_path("/static/app/pay/paypal.png"),
				'href'  => '',
			];
		}
		
		/*if($shelves==0 && $type==1){
			$paylist[]=[
				'id'=>'apple',
				'name'=>'苹果支付',
				'thumb'=>get_upload_path("/static/app/pay/apple.png"),
				'href'=>'',
			];
		}*/
		
		if($type == 1){
			$paylist[] = [
				'id'    => 'apple',
				'name'  => '苹果支付',
				'thumb' => get_upload_path("/static/app/pay/apple.png"),
				'href'  => '',
			];
		}
		
		
		$info['paylist'] = $paylist;
		$info['tip_t']   = $configpub['name_coin'].'/'.$configpub['name_score'].'说明:';
		$info['tip_d']   = $configpub['name_coin'].'可通过平台提供的支付方式进行充值获得，'.$configpub['name_coin'].'适用于平台内所有消费； '.$configpub['name_score'].'可通过直播间内游戏奖励获得，所得'.$configpub['name_score'].'可用于平台商城内兑换会员、坐 骑、靓号等服务，不可提现。';
		
		
		return $this->success(['0' => $info]);
	}
	
	// 钻石消费明细
	public function coinrecord()
	{
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		$p     = checkNull($this->p);
		$pnum  = checkNull($this->pnum);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		if($p < 1){
			$p = 1;
		}
		if($pnum < 1){
			$pnum = 20;
		}
		
		$start  = ($p - 1) * $pnum;
		$record = DI()->notorm->user_coinrecord
			->where('uid=?', $uid)->order("id desc")->limit($start, $pnum)->fetchAll();
		
		return $this->success($record);
	}
	
	
	/**
	 * 卡密兑换，卡密后台专用
	 * @desc 卡密兑换，卡密后台专用
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function exchange()
	{
		$uid    = checkNull($this->uid);
		$coin   = checkNull($this->coin);
		$domain = new Domain_User();
		$info   = $domain->exchange($uid, $coin);
		if(!$info){
			return $this->fail('卡密兑换失败!', 1001);
		}
		
		return $this->success([], '充值操作成功！');
	}
	
	/**
	 * 直冲，卡密后台专用
	 * @desc 直冲，卡密后台专用
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function charge()
	{
		$uid    = checkNull($this->uid);
		$coin   = checkNull($this->coin);
		$domain = new Domain_User();
		//需要判断扣除时候玩家余额是否足够
		if($coin < 0){
			$balance = $domain->getBalance($uid);
			if($balance['coin'] < abs($coin)){
				return $this->fail('玩家钻石余额：'.$balance['coin'].'，扣除失败！', 1001);
			}
		}
		
		$info = $domain->charge($uid, $coin);
		if(!$info){
			return $this->fail('直充失败!', 1001);
		}
		
		return $this->success([], '充值操作成功！');
	}
	
	/**
	 * 获取用户信息，卡密后台专用
	 * @desc 直冲，卡密后台专用
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function userInfo()
	{
		$uid    = checkNull($this->uid);
		$domain = new Domain_User();
		$info   = $domain->getBaseInfo($uid);
		if(!$info){
			return $this->fail('用户不存在!', 1001);
		}
		
		return $this->success($info);
	}
	############################################################################################################
	## 等级
	// 获取当前用户等级信息
	public function level()
	{
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		// 获取用户信息
		$userlevel = ['baifen' => 100, 'type' => '0'];
		$userinfo  = DI()->notorm->user->select("id,avatar,consumption,votestotal")->where("id=?", $uid)->fetchOne();
		
		/* 用户等级 */
		$levelinfo = DI()->notorm->level->where("level_up>=?", $userinfo['consumption'])->order("levelid asc")->fetchOne();
		if(empty($levelinfo)){
			$levelinfo = DI()->notorm->level->order("levelid desc")->fetchOne();
		}
		// 到下一等级差值
		$cha = $levelinfo['level_up'] + 1 - $userinfo['consumption'];
		if($cha > 0){
			if($levelinfo['level_up'] > 0){
				$baifen = floor($userinfo['consumption'] / $levelinfo['level_up'] * 100);
			} else{
				$baifen = '0';
			}
			$userlevel['baifen'] = $baifen;
			$userlevel['type']   = "1";
		}
		// 整理
		$userinfo['avatar'] = get_upload_path($userinfo['avatar']);
		$userlevel['cha']   = $cha;
		$userlevel['info']  = $levelinfo;
		
		/* 主播等级 */
		$livelevel = ['baifen' => 100, 'type' => '0'];
		$liveinfo  = DI()->notorm->level_anchor->where("level_up>=?", $userinfo['votestotal'])->order("levelid asc")->fetchOne();
		if(empty($liveinfo)){
			$liveinfo = DI()->notorm->level_anchor->order("levelid desc")->fetchOne();
		}
		// 到下一等级差值
		$cha_a = $liveinfo['level_up'] + 1 - $userinfo['votestotal'];
		if($cha_a > 0){
			if($liveinfo['level_up'] > 0){
				$baifen_a = floor($userinfo['votestotal'] / $liveinfo['level_up'] * 100);
			} else{
				$baifen_a = '0';
			}
			$livelevel['baifen'] = $baifen_a;
			$livelevel['type']   = "1";;
		}
		$livelevel['cha']  = $cha_a;
		$livelevel['info'] = $liveinfo;
		
		return $this->success(['userlevel' => $userlevel, 'userinfo' => $userinfo, 'livelevel' => $livelevel]);
	}
	
	// 获取所有的等级信息：用户等级
	public function getUserLevels()
	{
		$list = DI()->notorm->level->order("levelid asc")->fetchAll();
		foreach($list as $k => $v){
			$list[$k]['level_up'] = number_format($v['level_up']);
			$list[$k]['thumb']    = get_upload_path($v['thumb']);
		}
		
		return $this->success($list);
	}
	
	// 获取所有的等级信息：主播等级
	public function getLiveLevels()
	{
		$list = DI()->notorm->level_anchor->order("levelid asc")->fetchAll();
		foreach($list as $k => $v){
			$list[$k]['level_up'] = number_format($v['level_up']);
			$list[$k]['thumb']    = get_upload_path($v['thumb']);
		}
		
		return $this->success($list);
	}
	
	
	/**
	 * 查看每日任务
	 * @desc 用于用户查看每日任务的进度
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function seeDailyTasks()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid     = checkNull($this->uid);
		$token   = checkNull($this->token);
		$liveuid = checkNull($this->liveuid);
		$islive  = checkNull($this->islive);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$configpri        = getConfigPri();
		$dailytask_switch = $configpri['dailytask_switch'];
		if($islive == 1){   //判断请求是否在直播间
			if($uid == $liveuid){ //主播访问
				//主播直播计时---每日任务--取出用户时间
				$key       = 'open_live_daily_tasks_'.$uid;
				$starttime = getcaches($key);
				if($starttime){
					$endtime = time();  //当前时间
					$data    = ['type' => '3', 'starttime' => $starttime, 'endtime' => $endtime,];
					dailyTasks($uid, $data);
					//删除当前存入的时间
					delcache($key);
				}
				if($dailytask_switch){
					//主播直播计时---用于每日任务--记录主播请求时间
					$enterRoom_time = time();
					setcaches($key, $enterRoom_time);
				}
			} else{
				//用户访问
				//观看直播计时---每日任务--取出用户进入时间
				$key       = 'watch_live_daily_tasks_'.$uid;
				$starttime = getcaches($key);
				if($starttime){
					$endtime = time();  //当前时间
					$data    = ['type' => '1', 'starttime' => $starttime, 'endtime' => $endtime,];
					dailyTasks($uid, $data);
					//删除当前存入的时间
					delcache($key);
				}
				if($dailytask_switch){
					//观看直播计时---用于每日任务--记录用户进入时间
					$enterRoom_time = time();
					setcaches($key, $enterRoom_time);
				}
			}
		}
		
		$domain    = new Domain_User();
		$info      = $domain->seeDailyTasks($uid);
		$configpub = getConfigPub();
		$name_coin = $configpub['name_coin']; //钻石名称
		
		$rs['info'][0]['tip_m'] = "温馨提示：当您某个任务达成时就会获得平台奖励给您的{$name_coin}，获得的奖励需要您手动领取才可放入余额中，当日不领取次日系统会自动清零，亲爱的您一定要记得领取当日奖励哦~";
		$rs['info'][0]['list']  = $info;
		
		return $rs;
	}
	
	
	/**
	 * 领取每日任务奖励
	 * @desc 用于用户领取每日任务奖励
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function receiveTaskReward()
	{
		$uid    = checkNull($this->uid);
		$token  = checkNull($this->token);
		$taskid = checkNull($this->taskid);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			//return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$info   = $domain->receiveTaskReward($uid, $taskid);
		
		return $info;
	}
	
	############################################################################################################
	## 未整理
	
	/**
	 * 获取用户提现账号
	 * @desc 用于获取用户提现账号
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string info[].id 账号ID
	 * @return string info[].type 账号类型
	 * @return string info[].account_bank 银行名称
	 * @return string info[].account 账号
	 * @return string info[].name 姓名
	 * @return string msg 提示信息
	 */
	public function getUserAccountList()
	{
		$rs    = array('code' => 0, 'msg' => '', 'info' => array());
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$info   = $domain->getUserAccountList($uid);
		
		$rs['info'] = $info;
		
		return $rs;
	}
	
	/**
	 * 添加提现账号
	 * @desc 用于添加提现账号
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function setUserAccount()
	{
		$rs = array('code' => 0, 'msg' => '添加成功', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$type         = checkNull($this->type);
		$account_bank = checkNull($this->account_bank);
		$account      = checkNull($this->account);
		$name         = checkNull($this->name);
		if($type == 3){
			if($account_bank == ''){
				$rs['code'] = 1001;
				$rs['msg']  = '银行名称不能为空';
				
				return $rs;
			}
		}
		if($account == ''){
			$rs['code'] = 1002;
			$rs['msg']  = '账号不能为空';
			
			return $rs;
		}
		if(mb_strlen($account) > 40){
			$rs['code'] = 1002;
			$rs['msg']  = '账号长度不能超过40个字符';
			
			return $rs;
		}
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$data    = array('uid' => $uid, 'type' => $type, 'account_bank' => $account_bank, 'account' => $account, 'name' => $name, 'addtime' => time(),);
		$domain  = new Domain_User();
		$where   = ['uid' => $uid, 'type' => $type, 'account_bank' => $account_bank, 'account' => $account,];
		$isexist = $domain->getUserAccount($where);
		if($isexist){
			$rs['code'] = 1004;
			$rs['msg']  = '账号已存在';
			
			return $rs;
		}
		
		$result = $domain->setUserAccount($data);
		if(!$result){
			$rs['code'] = 1003;
			$rs['msg']  = '添加失败，请重试';
			
			return $rs;
		}
		
		$rs['info'][0] = $result;
		
		return $rs;
	}
	
	
	/**
	 * 删除用户提现账号
	 * @desc 用于删除用户提现账号
	 * @return int code 操作码，0表示成功
	 * @return array info
	 * @return string msg 提示信息
	 */
	public function delUserAccount()
	{
		$rs = array('code' => 0, 'msg' => '删除成功', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		$id    = checkNull($this->id);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$data   = array('uid' => $uid, 'id' => $id,);
		$domain = new Domain_User();
		$result = $domain->delUserAccount($data);
		if(!$result){
			$rs['code'] = 1003;
			$rs['msg']  = '删除失败，请重试';
			
			return $rs;
		}
		
		return $rs;
	}
	
	
	/**
	 * 用户申请店铺余额提现
	 * @desc 用于用户申请店铺余额提现
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function setShopCash()
	{
		$rs = array('code' => 0, 'msg' => '提现成功', 'info' => array());
		
		$uid       = checkNull($this->uid);
		$token     = checkNull($this->token);
		$accountid = checkNull($this->accountid);
		$money     = checkNull($this->money);
		$time      = checkNull($this->time);
		$sign      = checkNull($this->sign);
		
		if($uid < 0 || $token == "" || !$time || !$sign){
			$rs['code'] = 1001;
			$rs['msg']  = '参数错误';
			
			return $rs;
		}
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		if(!$accountid){
			$rs['code'] = 1001;
			$rs['msg']  = '请选择提现账号';
			
			return $rs;
		}
		if(!$money){
			$rs['code'] = 1002;
			$rs['msg']  = '请输入有效的提现金额';
			
			return $rs;
		}
		
		$now = time();
		if($now - $time > 300){
			$rs['code'] = 1001;
			$rs['msg']  = '参数错误';
			
			return $rs;
		}
		
		$checkdata = array('uid' => $uid, 'token' => $token, 'accountid' => $accountid, 'time' => $time,);
		$issign    = checkSign($checkdata, $sign);
		if(!$issign){
			$rs['code'] = 1001;
			$rs['msg']  = '签名错误';
			
			return $rs;
		}
		
		$configpri = getConfigPri();
		$data      = array('uid' => $uid, 'accountid' => $accountid, 'money' => $money,);
		$domain    = new Domain_User();
		$res       = $domain->setShopCash($data);
		
		if($res == 1001){
			$rs['code'] = 1001;
			$rs['msg']  = '余额不足';
			
			return $rs;
		} elseif($res == 1004){
			$rs['code'] = 1004;
			$rs['msg']  = '提现最低额度为'.$configpri['balance_cash_min'].'元';
			
			return $rs;
		} elseif($res == 1005){
			$rs['code'] = 1005;
			$rs['msg']  = '不在提现期限内，不能提现';
			
			return $rs;
		} elseif($res == 1006){
			$rs['code'] = 1006;
			$rs['msg']  = '每月只可提现'.$configpri['balance_cash_max_times'].'次,已达上限';
			
			return $rs;
		} elseif($res == 1007){
			$rs['code'] = 1007;
			$rs['msg']  = '提现账号信息不正确';
			
			return $rs;
		} elseif(!$res){
			$rs['code'] = 1002;
			$rs['msg']  = '提现失败，请重试';
			
			return $rs;
		}
		
		$rs['info'][0]['msg'] = '提现成功';
		
		return $rs;
	}
	
	/**
	 * 获取用户的认证信息
	 * @desc 用于获取用户的认证信息
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function getAuthInfo()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid        = checkNull($this->uid);
		$token      = checkNull($this->token);
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$isauth = isAuth($uid);
		if(!$isauth){
			$rs['code'] = 1001;
			$rs['msg']  = '请先进行实名认证';
			
			return $rs;
		}
		
		$domain = new Domain_User();
		$res    = $domain->getAuthInfo($uid);
		
		$rs['info'][0] = $res;
		
		return $rs;
	}
	
	/**
	 * 获取七牛上传Token
	 * @desc 用于获取七牛上传Token
	 * @return int code 操作码，0表示成功
	 * @return string msg 提示信息
	 */
	public function getQiniuToken()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		//获取后台配置的腾讯云存储信息
		$Qiniu = DI()->config->get('app.Qiniu');
		
		require_once API_ROOT.'/../sdk/qiniu/autoload.php';
		
		// 需要填写你的 Access Key 和 Secret Key
		// 需要填写你的 Access Key 和 Secret Key
		$accessKey        = $Qiniu['accessKey'];// $configpri['qiniu_accesskey'];
		$secretKey        = $Qiniu['secretKey'];//$configpri['qiniu_secretkey'];
		$bucket           = $Qiniu['space_bucket'];// $configpri['qiniu_bucket'];
		$qiniu_domain_url = $Qiniu['space_host'];
		// 构建鉴权对象
		$auth  = new Qiniu\Auth($accessKey, $secretKey);
		$token = $auth->uploadToken($bucket);  // 生成上传 Token
		// 整理
		$rs['info'][0]['token'] = $token;
		
		return $rs;
	}
	
	/**
	 * 用户设置美颜参数
	 * @desc 用于用户设置美颜参数
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function setBeautyParams()
	{
		$rs = array('code' => 0, 'msg' => '设置成功', 'info' => array());
		
		$uid    = checkNull($this->uid);
		$token  = checkNull($this->token);
		$params = $this->params;
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		} elseif($checkToken == 10020){
			$rs['code'] = 700;
			$rs['msg']  = '该账号已被禁用';
			
			return $rs;
		}
		
		$domain = new Domain_User();
		$res    = $domain->setBeautyParams($uid, $params);
		if(!$res){
			$rs['code'] = 1001;
			$rs['msg']  = '设置失败';
			
			return $rs;
		}
		
		return $rs;
	}
	
	/**
	 * 获取用户设置的美颜参数
	 * @desc 用于获取用户设置的美颜参数
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function getBeautyParams()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid        = checkNull($this->uid);
		$token      = checkNull($this->token);
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		} elseif($checkToken == 10020){
			$rs['code'] = 700;
			$rs['msg']  = '该账号已被禁用';
			
			return $rs;
		}
		
		$domain = new Domain_User();
		$res    = $domain->getBeautyParams($uid);
		// 整理
		$rs['info'][0] = $res;
		
		return $rs;
	}
	
	/**
	 * 用于APP端调用Braintree支付时的token验证
	 * @desc 用于APP端调用Braintree支付时的token验证
	 * @return int code 状态码,0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function getBraintreeToken()
	{
		$rs    = array('code' => 0, 'msg' => '', 'info' => array());
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			$rs['code'] = 700;
			$rs['msg']  = '您的登陆状态失效，请重新登陆！';
			
			return $rs;
		} elseif($checkToken == 10020){
			$rs['code'] = 700;
			$rs['msg']  = '该账号已被禁用';
			
			return $rs;
		}
		
		$getway_back = $this->getBrainTreeGateway();
		if($getway_back['code'] != 0){
			return $getway_back;
		} else{
			$gateway = $getway_back['info'];
		}
		
		$clientToken = $gateway->clientToken()->generate();
		
		$rs['info'][0]['braintreeToken'] = $clientToken;
		
		return $rs;
	}
	
	/**
	 * BrainTree支付回调
	 * @desc BrainTree支付回调
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function BraintreeCallback()
	{
		$rs = array('code' => 0, 'msg' => '回调成功', 'info' => array());
		return $rs;
		
		$uid       = checkNull($this->uid);
		$token     = checkNull($this->token);
		$orderno   = checkNull($this->orderno);
		$ordertype = checkNull($this->ordertype);
		$nonce     = checkNull($this->nonce);
		$money     = checkNull($this->money);
		$time      = checkNull($this->time);
		$sign      = checkNull($this->sign);
		
		
		//file_put_contents('./111111.txt',date('y-m-d H:i:s').' 提交参数信息:'.json_encode($nonce)."\r\n",FILE_APPEND);
		
		if(!in_array($ordertype, ['coin_charge', 'order_pay', 'paidprogram_pay'])){
			$rs['code'] = 1001;
			$rs['msg']  = '参数错误';
			
			return $rs;
		}
		
		if(!$nonce){
			$rs['code'] = 1002;
			$rs['msg']  = '三方订单编号错误';
			
			return $rs;
		}
		if(!$money){
			$rs['code'] = 1002;
			$rs['msg']  = '金额错误';
			
			return $rs;
		}
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$now = time();
		if($now - $time > 300){
			$rs['code'] = 1001;
			$rs['msg']  = '参数错误';
			
			return $rs;
		}
		
		$checkdata = array('uid' => $uid, 'ordertype' => $ordertype, 'orderno' => $orderno, 'time' => $time, 'nonce' => $nonce,);
		$issign    = checkSign($checkdata, $sign);
		if(!$issign){
			$rs['code'] = 1002;
			$rs['msg']  = '签名错误';
			
			return $rs;
		}
		
		$getway_back = $this->getBrainTreeGateway();
		if($getway_back['code'] != 0){
			return $getway_back;
		} else{
			$gateway = $getway_back['info'];
		}
		
		$sale   = ['amount' => $money, 'paymentMethodNonce' => $nonce, 'options' => ['submitForSettlement' => true],];
		$result = $gateway->transaction()->sale($sale);
		
		if($result->success){
			$domain = new Domain_User();
			$res    = $domain->BraintreeCallback($uid, $orderno, $ordertype, $nonce, $money);
			if($res == 1001){
				$rs['code'] = 1001;
				$rs['msg']  = '订单不存在';
				
				return $rs;
			}
			
			if($res == 1002){
				$rs['code'] = 1002;
				$rs['msg']  = '订单已支付';
				
				return $rs;
			}
			
			return $rs;
		} else{
			$rs['code'] = 1002;
			$rs['msg']  = '订单回调验证失败';
			
			return $rs;
			
		}
	}
	
	/**
	 * 获取BrainTreeGateway
	 */
	private function getBrainTreeGateway()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$configpri   = getConfigPri();
		$environment = $configpri['braintree_paypal_environment'];
		$merchantId  = '';
		$publicKey   = '';
		$privateKey  = '';
		
		if($environment == 0){ //沙盒
			$merchantId  = $configpri['braintree_merchantid_sandbox'];
			$publicKey   = $configpri['braintree_publickey_sandbox'];
			$privateKey  = $configpri['braintree_privatekey_sandbox'];
			$environment = 'sandbox';
			
		} else{ //生产
			
			$merchantId  = $configpri['braintree_merchantid_product'];
			$publicKey   = $configpri['braintree_publickey_product'];
			$privateKey  = $configpri['braintree_privatekey_product'];
			$environment = 'production';
			
		}
		
		if(!$merchantId || !$publicKey || !$privateKey){
			$rs['code'] = 1001;
			$rs['msg']  = 'BraintreePaypal未配置';
			
			return $rs;
		}
		
		$gateway = new Braintree\Gateway([
			'environment' => $environment,
			'merchantId'  => $merchantId,
			'publicKey'   => $publicKey,
			'privateKey'  => $privateKey,
		]);
		
		$rs['info'] = $gateway;
		
		return $rs;
	}
	
	/**
	 * 获取转盘中奖记录
	 * @desc 获取转盘中奖记录
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function getTurntableWinLists()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		$p     = checkNull($this->p);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		if($p < 1){
			$p = 1;
		}
		
		$domain = new Domain_User();
		$res    = $domain->getTurntableWinLists($uid, $p);
		// 整理
		$rs['info'] = $res;
		
		return $rs;
	}
	
	/**
	 * 清除转盘中奖记录
	 * @desc 清除转盘中奖记录
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function clearTurntableWinLists()
	{
		$rs = array('code' => 0, 'msg' => '清空成功', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$res    = $domain->clearTurntableWinLists($uid);
		
		return $rs;
	}
	
	/**
	 * 检查用户是否开启了青少年模式
	 * @desc 检查用户是否开启了青少年模式
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 * @return array info[0].is_setpassword 是否设置过密码 0 否 1 是
	 * @return array info[0].status 是否开启青少年模式 0 否 1 是
	 * @return array info[0].is_tip 是否提示用户弹窗显示青少年模式下不能继续使用app   0 否  1 是
	 * @return array info[0].tips  弹窗显示青少年模式下不能继续使用app的提示语
	 * @return array info[0].teenager_des  青少年模式提示语
	 */
	public function checkTeenager()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain    = new Domain_User();
		$res       = $domain->checkTeenager($uid);
		$configpub = getConfigPub();
		// 整理
		$res['info'][0]['is_tip']       = '0';
		$res['info'][0]['tips']         = '';
		$res['info'][0]['teenager_des'] = $configpub['teenager_des'];
		
		//开启了青少年模式
		if($res['info'][0]['is_setpassword'] && $res['info'][0]['status']){
			$overtime = $domain->checkTeenagerIsOvertime($uid);
			
			if($overtime['code'] != 0){
				$res['info'][0]['is_tip'] = '1';
				$res['info'][0]['tips']   = $overtime['msg'];
			}
		}
		
		return $res;
	}
	
	/**
	 * 用户开启青少年模式/初次设置密码后重新设置密码
	 * @desc 用户开启青少年模式/初次设置密码后重新设置密码
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function setTeenagerPassword()
	{
		$rs = array('code' => 0, 'msg' => '青少年模式开启成功', 'info' => array());
		
		$uid      = checkNull($this->uid);
		$token    = checkNull($this->token);
		$password = checkNull($this->password);
		$type     = checkNull($this->type);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		if(mb_strlen($password) != 4){
			$rs['code'] = 1001;
			$rs['msg']  = '密码必须为4位';
			
			return $rs;
		}
		
		$domain = new Domain_User();
		$res    = $domain->setTeenagerPassword($uid, $password, $type);
		if($res == 1001){
			$rs['code'] = 1002;
			$rs['msg']  = '密码错误';
			
			return $rs;
		}
		if($res == 1002){
			$rs['code'] = 1003;
			$rs['msg']  = '密码设置失败,请稍后重试';
			
			return $rs;
		}
		
		return $rs;
	}
	
	/**
	 * 用户修改青少年模式密码
	 * @desc 用户修改青少年模式密码
	 * @return int code 状态码,0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function updateTeenagerPassword()
	{
		$rs = array('code' => 0, 'msg' => '密码修改成功', 'info' => array());
		
		$uid         = checkNull($this->uid);
		$token       = checkNull($this->token);
		$oldpassword = checkNull($this->oldpassword);
		$password    = checkNull($this->password);
		if(!$oldpassword){
			$rs['code'] = 1001;
			$rs['msg']  = '请输入原密码';
			
			return $rs;
		}
		if(mb_strlen($oldpassword) != 4){
			$rs['code'] = 1002;
			$rs['msg']  = '原密码长度必须为4位';
			
			return $rs;
		}
		if(!$password){
			$rs['code'] = 1001;
			$rs['msg']  = '请输入新密码';
			
			return $rs;
		}
		if(mb_strlen($password) != 4){
			$rs['code'] = 1002;
			$rs['msg']  = '新密码长度必须为4位';
			
			return $rs;
		}
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$res    = $domain->updateTeenagerPassword($uid, $oldpassword, $password);
		if($res == 1001){
			$rs['code'] = 1003;
			$rs['msg']  = '你还未设置密码';
			
			return $rs;
		}
		if($res == 1002){
			$rs['code'] = 1004;
			$rs['msg']  = '原密码错误';
			
			return $rs;
		}
		if(!$res){
			$rs['code'] = 1005;
			$rs['msg']  = '密码修改失败';
			
			return $rs;
		}
		
		return $rs;
	}
	
	/**
	 * 用户关闭青少年模式
	 * @desc 用户关闭青少年模式
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function closeTeenager()
	{
		
		$rs = array('code' => 0, 'msg' => '青少年模式关闭成功', 'info' => array());
		
		$uid      = checkNull($this->uid);
		$token    = checkNull($this->token);
		$password = checkNull($this->password);
		if(!$password){
			$rs['code'] = 1001;
			$rs['msg']  = '请输入密码';
			
			return $rs;
		}
		
		if(mb_strlen($password) != 4){
			$rs['code'] = 1002;
			$rs['msg']  = '密码长度必须为4位';
			
			return $rs;
		}
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$res    = $domain->closeTeenager($uid, $password);
		if($res == 1001){
			$rs['code'] = 1003;
			$rs['msg']  = '你还未开启青少年模式';
			
			return $rs;
		}
		if($res == 1002){
			$rs['code'] = 1004;
			$rs['msg']  = '青少年模式未开启';
			
			return $rs;
		}
		if($res == 1003){
			$rs['code'] = 1005;
			$rs['msg']  = '密码错误';
			
			return $rs;
		}
		if(!$res){
			$rs['code'] = 1006;
			$rs['msg']  = '青少年模式关闭失败';
			
			return $rs;
		}
		
		return $rs;
	}
	
	/**
	 * 定时增加用户使用青少年模式时间
	 * @desc 定时增加用户使用青少年模式时间
	 * @return int code 状态码，0表示成功
	 * @return string msg 提示信息
	 * @return array info 返回信息
	 */
	public function addTeenagerTime()
	{
		$rs = array('code' => 0, 'msg' => '', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		
		$domain = new Domain_User();
		$res    = $domain->addTeenagerTime($uid);
		
		return $res;
	}
	
	
	/**
	 * 更换个人中心背景图
	 * @desc 更换个人中心背景图
	 * @retun int code 状态码,0表示成功
	 * @retun string msg 返回信息
	 * @retun array info 返回信息
	 * @retun array info[0]['bg_img'] 返回上传的背景图
	 * */
	public function updateBgImg()
	{
		$rs = array('code' => 0, 'msg' => '背景图更换成功', 'info' => array());
		
		$uid   = checkNull($this->uid);
		$token = checkNull($this->token);
		$img   = checkNull($this->img);
		
		$checkToken = checkToken($uid, $token);
		if($checkToken == 700){
			return $this->fail('您的登陆状态失效，请重新登陆！', $checkToken);
		}
		if(!$img){
			$rs['code'] = 1001;
			$rs['msg']  = '请上传背景图';
			
			return $rs;
		}
		
		$domain = new Domain_User();
		$res    = $domain->updateBgImg($uid, $img);
		if($res == 1001){
			$rs['code'] = 1002;
			$rs['msg']  = '背景图更换失败';
			
			return $rs;
		}
		
		$userinfo = getUserInfo($uid);
		// 整理
		$rs['info'][0]['bg_img'] = $userinfo['bg_img'];
		
		return $rs;
	}
	
	
}
